<template>
  <div>
    <yt-card title="基本信息">
      <yt-cell label="事故企业" :value="item.enterprise_name"></yt-cell>
      <yt-cell label="事故类型" :value="item.accident_type"></yt-cell>
      <yt-cell label="事发地点" :value="item.accident_place"></yt-cell>
      <yt-cell label="事发时间" :value="item.createdAt | formatTime"></yt-cell>
      <yt-textarea disabled title="初步原因" v-model="item.preliminary_cause"></yt-textarea>
      <yt-textarea disabled title="简要经过" v-model="item.things_go_through"></yt-textarea>
    </yt-card>
    <yt-card title="报告人信息">
      <yt-cell label="所在部门" :value="item.text"></yt-cell>
      <yt-cell label="报警人" :value="item.name"></yt-cell>
      <yt-cell label="职务" :value="item.post"></yt-cell>
      <yt-cell label="报警电话" border="none">
        <yt-cell-call :tel="item.telephone || ''"></yt-cell-call>
      </yt-cell>
    </yt-card>
    <yt-card title="伤亡情况">
      <yt-cell label="死亡人数" :value="`${item.Casualty || 0}人（预估）`"></yt-cell>
      <yt-cell label="重伤人数" :value="`${item.serious_injury || 0}人（预估）`"></yt-cell>
      <yt-cell label="经济损失" :value="`${item.economics || 0}万元（预估）`"></yt-cell>
      <yt-textarea disabled title="撤离情况" v-model="item.evacuate"></yt-textarea>
      <yt-textarea disabled title="环境影响" v-model="item.contaminated"></yt-textarea>
      <yt-textarea disabled title="协调事项" v-model="item.help"></yt-textarea>
    </yt-card>
    <yt-card title="附件">
      <yt-file v-model="item.file" :uploadFile="()=> {}" :disabled="true"></yt-file>
    </yt-card>
  </div>
</template>

<script>
  import { commonApi } from '@/common/api/commonApi.js'
  import { ReplaceDictionary } from '@/common/utils/index.js'
  export default {
    data() {
      return {
        item: {}
      }
    },
    props: {
      id: {}
    },
    methods: {
      /**
       * yj_emergency_information 事故信息表
       */
      async initData () {
        let p = [
          commonApi.searchById('yj_emergency_information', this.id),
          commonApi.search('ent_enterprise'),
          commonApi.dictionary('Accident_type')
        ]
        let [ item, entList, accidentTypeDic ] = await Promise.all(p)

        this.item = await ReplaceDictionary(item, {
          accident_type: accidentTypeDic,
          "enterprise_name:EnterpriseName:id": entList
        })
      }
    },
    watch: {
      id () {
        this.initData()
      }
    }
  }
</script>
